package com.wskj.common.utils.common;

import cn.hutool.core.util.RandomUtil;
import com.wskj.common.constant.Constants;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * 生成用户账号
 * @author gun
 */
@Slf4j
public class CommonUtils {

    public static String generateName() {
        return generateName(null);
    }

    public static String generateName(String tel) {
        String suf = RandomUtil.randomNumbers(6);
        if (Objects.nonNull(tel)) {
            suf = StringUtils.substring(tel, tel.length() - 6, tel.length());
        }
        return Constants.USER_NAME_PREFIX + suf;
    }

    /**
     * 获取随机推荐码
     * @return
     */
    public static String getRecommendCode(){
        String suf = RandomUtil.randomNumbers(8);
        return suf;
    }
}
